package com.wzdigit.wms.basic.mapper.core.inventory;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wzdigit.framework.orm.mybatis.MyBatisRepository;
import com.wzdigit.wms.basic.client.request.inv.SearchQualifiedGoodsRequest;
import com.wzdigit.wms.basic.client.request.inv.SearchSealGoodsGroupRequest;
import com.wzdigit.wms.basic.client.request.transfer.SearchInvRequest;
import com.wzdigit.wms.basic.client.request.transfer.SingleStepTransferReq;
import com.wzdigit.wms.basic.client.response.inv.QualifiedGoodsResponse;
import com.wzdigit.wms.basic.client.response.inv.SealGoodsGroupResponse;
import com.wzdigit.wms.basic.client.response.outstock.LocResponse;
import com.wzdigit.wms.basic.client.response.report.ScanSnResponse;
import com.wzdigit.wms.basic.client.response.transfer.HeapAndMergerResponse;
import com.wzdigit.wms.basic.client.response.transfer.InvLocGoodsListResponse;
import com.wzdigit.wms.basic.client.response.transfer.TransferTaskScanSnResponse;
import com.wzdigit.wms.basic.domain.dtos.inventory.PrintSnDataDto;
import com.wzdigit.wms.basic.domain.dtos.inventory.UpdateInventoryInputDto;
import com.wzdigit.wms.basic.domain.dtos.report.MaterialPeakDto;
import com.wzdigit.wms.basic.domain.dtos.report.WarehousePeakDto;
import com.wzdigit.wms.basic.domain.inventory.Goods;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

@MyBatisRepository
public interface GoodsMapper extends BaseMapper<Goods> {
	
	List<Map<String, Object>> selectTest();
	/**
	 * 根据库位库存查找条码
	 * @param dto
	 * @return
	 */
	List<InvLocGoodsListResponse> selectByInvLoc(@Param("dto") SearchInvRequest dto);

	//PDA扫描SN获取条码信息
	ScanSnResponse selectSnInfo(@Param("goodsSn") String goodsSn);

	ScanSnResponse selectSnHisInfo(@Param("goodsSn") String goodsSn);
	
	List<Integer> selectLocIdListBySkuIdAndWhsIdOrPoNo(@Param("skuId") Integer skuId, 
			@Param("whsId") Integer whsId, @Param("poNo") String poNo);

	Integer selectPkgIdBySn(@Param("sn") String sn);

	List<Goods> selectBySNs(@Param("SNs") List<String> SNs);
	
	List<String> selectPrdWoListByListSn(@Param("SNs") List<String> SNs);

	List<UpdateInventoryInputDto> selectUpdateList(@Param("SNs") List<String> SNs);

	List<SealGoodsGroupResponse> selectSealGoodsGroup(SearchSealGoodsGroupRequest dto);
	
	List<QualifiedGoodsResponse> selectQualifiedGoods(
			@Param("dto") SearchQualifiedGoodsRequest dto,
			@Param("qaStatus") Integer qaStatus,
			@Param("goodsIdList") List<Integer> goodsIdList);
	
	Goods selectBySn(@Param("goodsSn") String goodsSn);

	HeapAndMergerResponse selectHeapBySn(@Param("goodsSn") String goodsSn);
	

	Integer updatePkgIdBySnList(@Param("snList") List<String> snList, @Param("pkgId") Integer pkgId,
			@Param("modifyUser") String modifyUser);

	void updatePkgIdAndStatusAndWhsIdBySnList(@Param("snList") List<String> snList,
											  @Param("goodsPkgId")  Integer goodsPkgId,
											  @Param("status") Integer status,
											  @Param("whsId") Integer whsId,
											  @Param("modifyUser") String modifyUser);

	void batchUpdateStatus(@Param("sns") List<String> sns, @Param("status") Integer status);
	
	void batchUpdateQaStatus(@Param("qaStatus") Integer qaStatus, @Param("modifyUser") String modifyUser,
			@Param("goodsIdList") List<Integer> goodsIdList);

//	List<TransferTaskScanSnResponse> getOnConditionSingleStepTransfer(@Param("singleStepTransferReq") SingleStepTransferReq singleStepTransferReq,
//			@Param("waitUpCode") Integer waitUpCode, @Param("hasUpCode") Integer hasUpCode);

	int updateGoodsNullByGoodsId(Goods goodsUpdate);

	int updatePkgIdById(Goods goods);

	int updateGoodsDePackage(Goods goods);

	int updateLocIdAndPkgIdAndStatusById(Goods goods);

	int updateLocIdAndStatusById(Goods goods);
	
	int updateWhsIdAndLocIdAndStatusById(Goods goods);

	List<TransferTaskScanSnResponse> getOnConditionSingleStepTransfer(@Param("singleStepTransferReq") SingleStepTransferReq singleStepTransferReq, @Param("allowStatusList") List<Integer> allowStatusList);

	Integer updateWhsIdBySns(@Param("goods") Goods goods,@Param("snList") List<String> snList);

    Integer updateGoodsSetLocNull(Goods goods);

	List<LocResponse> selectAllLocIdBySkuId(@Param("skuId") Integer skuId, @Param("locId") Integer locId);

	int splitQty(@Param("goodsId") Integer goodsId, @Param("splitQty") BigDecimal splitQty, @Param("nowDate") Date nowDate, @Param("loginName") String loginName);

	List<PrintSnDataDto> selectPrintSnData(@Param("goodsIdList") List<Integer> goodsIdList);

    List<WarehousePeakDto> selectCurWarehousePeak();


	List<MaterialPeakDto> selectMaterialPeak();

	String  getSkucodeBySn(@Param("goodSn") String goodSn);


}
